package com.javasm.transfer;

import com.javasm.domin.entity.AftersaleEnterDepotDetail;
import com.javasm.domin.vo.AftersaleEnterDepotDetailVo;
import com.javasm.mapper.DepotDictMapper;
import com.javasm.transfer.base.BaseTransfer;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

import static com.javasm.common.dictionary.InitContext.dic;

/**
 * @Author：longjinyi
 * @Version：1.0
 * @Date：2022/1/20-17:49
 * @Since:jdk1.8
 * @Description:
 */
@Component
@RequiredArgsConstructor
public class AftersaleEnterDepotDetailTransfer extends BaseTransfer<AftersaleEnterDepotDetail, AftersaleEnterDepotDetailVo> {

    private final DepotDictMapper depotDictMapper;

    @Override
    public List<AftersaleEnterDepotDetailVo> toVO(List<AftersaleEnterDepotDetail> list) {
        List<AftersaleEnterDepotDetailVo> aftersaleEnterDepotDetailVos = super.toVO(list);

        for (int i = 0; i < aftersaleEnterDepotDetailVos.size(); i++) {
            AftersaleEnterDepotDetail aftersaleEnterDepotDetail = list.get(i);
            AftersaleEnterDepotDetailVo aftersaleEnterDepotDetailVo = aftersaleEnterDepotDetailVos.get(i);

            if (aftersaleEnterDepotDetail.getSnIschange() != null && aftersaleEnterDepotDetail.getSnIschange() != 0) {
                aftersaleEnterDepotDetailVo.setSnIschange(dic.get(16).get(aftersaleEnterDepotDetail.getSnIschange()));
            }

            if (aftersaleEnterDepotDetail.getOutType() != null && aftersaleEnterDepotDetail.getOutType() != 0) {
                aftersaleEnterDepotDetailVo.setOutType(dic.get(4).get(aftersaleEnterDepotDetail.getOutType()));
            }
        }

        return aftersaleEnterDepotDetailVos;
    }
}
